module scene.ray;

import utils.vector3;

struct Ray {
    Vector3f start;
    Vector3f dir;
    float tMax;

    int sign[3];
    Vector3f invDir;

    Vector3f rdif_dPx, rdif_dPy;
    Vector3f rdif_dDx, rdif_dDy;

    public static Ray opCall(Vector3f start, Vector3f dir, float tMax) {
        Ray res;
        res.start = start;
        res.dir = dir;
        res.tMax = tMax;
        res.invDir = Vector3f(1.0f/res.dir.x, 1.0f/res.dir.y, 1.0f/res.dir.z);
        res.sign[0] = (res.invDir.x < 0);
        res.sign[1] = (res.invDir.y < 0);
        res.sign[2] = (res.invDir.z < 0);
        return res;
    }
}
